﻿using Api.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Api.Core.IRepository
{
    public interface IBaseRepository<TEntity> where TEntity : class
    {
        Task<int> Add(TEntity entity);
        Task<int> Add(List<TEntity> listEntity);
        Task<bool> Update(TEntity entity);
        Task<bool> DeleteByIds(int[] ids);
        Task<bool> DeleteById(object id);
        Task<List<TEntity>> Query();
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
        Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
        Task<PageModel<TResult>> QueryMuch<T, T2, T3, TResult>(
           int intPageIndex,
           int intPageSize,
           string strOrderByFileds,
           string where,
           Expression<Func<T, T2, T3, object[]>> joinExpression,
           Expression<Func<T, T2, T3, TResult>> selectExpression
           ) where T : class, new();
    }
}
